package cn.linjianhui.interview.patterns.singleton;

// 双重检查锁，优化懒汉模式
public class Lock2Singleton {
    private volatile static Lock2Singleton singleton;

    private Lock2Singleton() {

    }

    public static Lock2Singleton getInstance() {
        if(singleton == null) {
            synchronized (singleton) {
                if(singleton == null) {
                    singleton = new Lock2Singleton();
                }
            }
        }
        return singleton;
    }
}
